# Maintainer: r4sas <r4sas@i2pmail.org>
# Contributor: l-n-s <supervillain@riseup.net>
pkgname=i2pd
pkgver=2.50.2
pkgrel=1
pkgdesc="I2P Router written in C++"
url="https://i2pd.website"
arch="all"
license="BSD-3-Clause"
pkgusers="i2pd"
makedepends="boost-dev miniupnpc-dev openssl-dev>3 openssl zlib-dev"
options="!check" # No test suite
install="$pkgname.pre-install"
source="https://github.com/PurpleI2P/i2pd/archive/$pkgver/i2pd-$pkgver.tar.gz
	i2pd.initd
	i2pd.confd
	"
subpackages="$pkgname-dbg $pkgname-openrc"

build() {
	local _arch_opts=

	case "$CARCH" in
		aarch64*|arm*) _arch_opts="USE_UPNP=yes USE_AESNI=no" ;;
		*)             _arch_opts="USE_UPNP=yes" ;;
	esac

	make $_arch_opts
}

package() {

	install -D -m 755 i2pd "$pkgdir"/usr/sbin/i2pd

	install -dm755 -o $pkgusers \
		"$pkgdir"/etc/$pkgname \
		"$pkgdir"/usr/share/$pkgname \
		"$pkgdir"/var/lib/$pkgname \
		"$pkgdir"/var/log/$pkgname

	install -D -m 644 contrib/tunnels.conf "$pkgdir"/etc/i2pd/tunnels.conf
	install -D -m 644 contrib/i2pd.conf "$pkgdir"/etc/i2pd/i2pd.conf
	install -D -m 644 contrib/i2pd.logrotate "$pkgdir"/etc/logrotate.d/i2pd
	cp -r contrib/certificates/ "$pkgdir"/usr/share/$pkgname/certificates
	ln -s /usr/share/$pkgname/certificates "$pkgdir"/var/lib/$pkgname/certificates

	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="
7df7a578711a959feee4326060829cf87c0d1669e473934549cb59d868a7aef7300ecd2d7a6b92a2295aa7e97964cc16d0e44a334db917e22b0b59573a9052de  i2pd-2.50.2.tar.gz
fae08de6cbdb5097cb3068d9a87509195d607fe666db870a3264f952fb3fceafc665168bd16bf598597617e48322301bbc900dcbd2c38fefca419d4755cea5f9  i2pd.initd
5b767037b49a9d94ac12dcc014a34c63967ab16a3292dd2622a118326c8d54905213d9638e48903cf0115c69b37490f648d3b2a78a1099063af78178b7024c75  i2pd.confd
"
